package com.ap.core.dao.impl;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import com.ap.core.cxf.jaxb.common.ActivationStatus;
import com.ap.core.dao.AbstractReadOnlyAPCoreBaseJpaDao;
import com.ap.core.dao.DistributorDao;
import com.ap.core.domain.Distributor;

/**
 * User: Rohit.Dixit
 * Jpa Implementation class for {@link com.ap.core.dao.DistributorDao}
 */
public class JpaDistributorDao extends AbstractReadOnlyAPCoreBaseJpaDao<Distributor, Long> implements DistributorDao{

    @Override
    public Distributor findById(Long primaryKey) {
        return findById(Distributor.class, primaryKey);
    }

	@Override
	public Distributor getDistributorByIdentification(String distIdentification) {
        Criteria criteria = getSession().createCriteria(Distributor.class);
        criteria.add(Restrictions.eq("distributorIdentification", distIdentification));
       // criteria.add(Restrictions.eq("activationStatusCode", ActivationStatus.ACTIVE));
       return (Distributor)criteria.uniqueResult();
	}
}
